import { ERMICallModel } from "./ERMICallModel";
import { SerializeStream } from "../../Framework/Serialize/SerializeStream";
import { MarshalException } from "./MarshalException";
type int = number;
//class ERMIMessageType

export class ERMIMessageType {
  constructor(arg1: int) {
    this.__value = arg1;
    ERMIMessageType.__values[arg1] = this;
  }

  public value(): int {
    return this.__value;
  }

  public toString(): string {
    return ERMIMessageType.__T[this.__value];
  }

  public equals(arg1: ERMICallModel | null): Boolean {
    if (this == arg1) {
      return true;
    }
    if (arg1 == null) {
      return false;
    }
    return this.__value == arg1.value();
  }

  public hashCode(): int {
    return 5 * this.__value;
  }

  public __write(stream: SerializeStream): void {
    stream.writeByte(this.__value);
    return;
  }

  public static convert(code: int): ERMIMessageType {
    return ERMIMessageType.__values[code];
  }

  public static __read(arg1: SerializeStream): ERMIMessageType {
    var loc1 = arg1.readByte();
    if (loc1 < 0 || loc1 >= 5) {
      throw new MarshalException();
    }
    return ERMIMessageType.convert(loc1);
  }

  private static /* const */ __T: Array<any> = [
    "ERMIMessageType.MessageTypeCall",
    "ERMIMessageType.MessageTypeCallRet",
    "ERMIMessageType.MessageTypeCallRedirect",
    "ERMIMessageType.MessageTypeCallRetRedirect",
    "ERMIMessageType.MessageTypeMQ"
  ];

  private static /* var */ __values: Array<ERMIMessageType> = [];

  public static /* const */ _MessageTypeCall: int = 0;

  public static /* const */ MessageTypeCall: ERMIMessageType = new ERMIMessageType(
    ERMIMessageType._MessageTypeCall
  );

  public static /* const */ _MessageTypeCallRet: int = 1;

  public static /* const */ MessageTypeCallRet: ERMIMessageType = new ERMIMessageType(
    ERMIMessageType._MessageTypeCallRet
  );

  public static /* const */ _MessageTypeCallRedirect: int = 2;

  public static /* const */ MessageTypeCallRedirect: ERMIMessageType = new ERMIMessageType(
    ERMIMessageType._MessageTypeCallRedirect
  );

  public static /* const */ _MessageTypeCallRetRedirect: int = 3;

  public static /* const */ MessageTypeCallRetRedirect: ERMIMessageType = new ERMIMessageType(
    ERMIMessageType._MessageTypeCallRetRedirect
  );

  public static /* const */ _MessageTypeMQ: int = 4;

  public static /* const */ MessageTypeMQ: ERMIMessageType = new ERMIMessageType(
    ERMIMessageType._MessageTypeMQ
  );

  public /* var */ __value: int;
}
